//var tmodel = new zxt.data.TunnelTableModel("CARDG1");
//tmodel.method("query", "insert", "update", "remove");

var tmodel = new zxt.data.TunnelTableModel();
tmodel.method("query", "insert", "update", "remove");
		
function onInitialize(dw){	
};			

function configMainGrid(grid){	
	grid.getColumn("sex").conf(c4sex);
	grid.getColumn("vip").conf(c4vip);
	
	var typeC = new zxt.data.Composite();	
	var model = new zxt.data.TunnelTableModel("PRODS");
	model.method("query");	
	
	var param = {};
	param.id = "123";
	model.setParam(param);
	
	typeC.append(model);	
	var types = [];
	typeC.loadTo(types);
	grid.getColumn("type").conf(types);
	
	/**
	grid.rowClicked = function(dom, idx){
		var row = grid.getRowData(idx);
		location.href = "loc.to?page=CARD&ID=" + row["id"];
	};**/
	
	grid.rowDoubleClicked = function(dom, idx){				
		var row = grid.getRowData(idx);
		var dw = new zxt.data.DataWrapper();
		dw.components(row);
		$zxt.submit(dw, "cvs","CARD","onClick$Query");
	};
			
	
};

function onClick$Query(){	
	
	var cb = {
		onSuccess : function(dw) {
			//var name = dw.getSheet("result").attrs().Name;
			//$zxtUI.Name.renderValue(name);
		},
		onFailure : function(xmlR, status, e) {
			
		}
	};

	tmodel.callback(cb);

	var param = {};
	param.ID = $zxtUI.ID.getValue();

	tmodel.setParam(param);

};

function onClick$Create(){
	$zxtUI.grid.create();	
};

function onClick$Save(){
	var param = {};
	param.ID = $zxtUI.ID.getValue();
	$zxtUI.grid.save(param);
};		

function onClick$Delete(){
	var param = {};
	param.ID = $zxtUI.ID.getValue();
	$zxtUI.grid.remove(param);
};	

function onClick$Print(){
	var sheet = zxt.help.getGridSheet(tmodel,$zxtUI.grid);
	var dw = new zxt.data.DataWrapper();
	zxt.help.addComponetLabel(dw);
	dw.addSheet(sheet);
	dw.set("name", "cupdata");	
	zxt.dom.openPage("cvs", "PRINT", "print", dw, false);
};

function onClick$Clear(){
	tmodel.clear();
};	


